/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.mecca.modelo;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

/**
 *
 * @author x
 */
public class Conexion {
    public Statement st;
    public ResultSet rs;
    public Connection cn;
    
    public Connection getConexion(){
        try {
            Context init = new InitialContext();
            Context context = (Context) init.lookup("java:comp/env");
            DataSource dataSource = (DataSource)context.lookup("jdbc/mysql");
            cn = dataSource.getConnection();
            }
        catch (Exception e) {
            System.out.println(e.getMessage()); 
             }
        finally{
            return cn;
            }
        }
    }